package com.nowar.common.exception;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import sun.net.idn.Punycode;

/**
 * 业务异常
 *
 * @Author: 谢无殇。
 * @Date : 2023-01-15 22:05
 */
@Getter
@Setter
@Builder
public class BBException extends RuntimeException {
    /**
     * 错误码
     */
    private int code;
    /**
     * 错误信息
     */
    private String message;

    public BBException() {
    }

    public BBException(int code) {
        this.code = code;
    }

    public BBException(String message) {
        super(message);
        this.message = message;
    }

    public BBException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public BBException(String message, Throwable cause) {
        super(message, cause);
    }

    public BBException(Throwable cause) {
        super(cause);
    }


    public static BBException getInstance(int code) {
        return new BBException(code);
    }

    public static BBException getInstance(String message) {
        return new BBException(message);
    }

    public static BBException getInstance(int code, String message) {
        return new BBException(code, message);
    }

}
